import { IPSDEField } from '../defield/ipsdefield';
import { IPSDERAggData } from './ipsderagg-data';
import { IPSDERAggDataDEFieldMap } from './ipsderagg-data-defield-map';
import { IPSSysSFPlugin } from '../../res/ipssys-sfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDERAggDataDEFieldMapImpl extends PSModelObjectImpl implements IPSDERAggDataDEFieldMap {
  get codeName(): string {
    return this.M.codeName;
  }

  get drillDownCondFormat(): string {
    return this.M.drillDownCondFormat;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get formulaFormat(): string {
    return this.M.formulaFormat;
  }

  protected majorpsdefield: IPSDEField | null = null;

  getMajorPSDEField(): IPSDEField | null {
    if (this.majorpsdefield != null) return this.majorpsdefield;
    const value = this.M.getMajorPSDEField;
    if (value == null) {
      return null;
    }
    const ipsderaggdata = this.getParentPSModelObject('dataentity.der.IPSDERAggData') as IPSDERAggData;
    if (ipsderaggdata != null) {
      this.majorpsdefield = ipsderaggdata.getMajorPSDataEntityMust().findPSDEField(value);
    }
    return this.majorpsdefield;
  }

  get majorPSDEField(): IPSDEField | null {
    return this.getMajorPSDEField();
  }

  getMajorPSDEFieldMust(): IPSDEField {
    const value = this.getMajorPSDEField();
    if (value == null) {
      throw new Error('未指定主实体属性');
    }
    return value;
  }

  get mapType():
    | 'SUM'
    | 'AVG'
    | 'MAX'
    | 'MIN'
    | 'COUNT'
    | 'GROUPBY'
    | 'GROUPBY_DAYOFWEEK'
    | 'GROUPBY_DAYOFMONTH'
    | 'GROUPBY_DAYOFYEAR'
    | 'GROUPBY_WEEK'
    | 'GROUPBY_MONTH'
    | 'GROUPBY_QUARTER'
    | 'GROUPBY_YEAR'
    | 'GROUPBY_HOUR'
    | 'GROUPBY_MINUTE'
    | 'USER'
    | 'USER2'
    | 'USER3'
    | 'USER4' {
    return this.M.mapType;
  }

  get memo(): string {
    return this.M.memo;
  }

  protected minorpsdefield: IPSDEField | null = null;

  getMinorPSDEField(): IPSDEField | null {
    if (this.minorpsdefield != null) return this.minorpsdefield;
    const value = this.M.getMinorPSDEField;
    if (value == null) {
      return null;
    }
    const ipsderaggdata = this.getParentPSModelObject('dataentity.der.IPSDERAggData') as IPSDERAggData;
    if (ipsderaggdata != null) {
      this.minorpsdefield = ipsderaggdata.getMinorPSDataEntityMust().findPSDEField(value);
    }
    return this.minorpsdefield;
  }

  get minorPSDEField(): IPSDEField | null {
    return this.getMinorPSDEField();
  }

  getMinorPSDEFieldMust(): IPSDEField {
    const value = this.getMinorPSDEField();
    if (value == null) {
      throw new Error('未指定从实体属性');
    }
    return value;
  }

  get name(): string {
    return this.M.name;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后台扩展插件');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSDERAggDataDEFieldMapImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.der.IPSDERAggDataDEFieldMap') return true;
    return super.instanceof(cls);
  }
}
